package flst.ipiweb.common;

import java.util.Random;

public class User {
	private int id;
	private String login;
	private String password;
	private String email;
	private String firstName;
	private String lastName;
	private boolean isAdmin;
	private boolean isSuperAdmin;
	private Basket basket;

	public User() {
		Random r = new Random();
		this.setId(r.nextInt(Integer.MAX_VALUE));
	}

	public User(int id) {
		this.setId(id);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public boolean getIsAdmin() {
		return isAdmin;
	}

	public void setAdmin(boolean isAdmin) {
		if (!isAdmin)
			this.setSuperAdmin(false);
		this.isAdmin = isAdmin;
	}

	public boolean getIsSuperAdmin() {
		return isSuperAdmin;
	}

	public void setSuperAdmin(boolean isSuperAdmin) {
		if (isSuperAdmin)
			this.setAdmin(true);
		this.isSuperAdmin = isSuperAdmin;
	}

	public void generateNewRandomId() {
		Random r = new Random();
		this.id = r.nextInt(Integer.MAX_VALUE);
	}
}
